<template>

 <div>
   <span >
      <el-date-picker
        style="margin-top: 20px"
        v-model="times.startTime"
        type="datetime"
        placeholder="选择日期时间">
   </el-date-picker>
   ——
   <el-date-picker
     v-model="times.endTime"
     type="datetime"
     placeholder="选择日期时间">
   </el-date-picker>
     <el-button icon="el-icon-search" round type="primary" @click="selectMoneyCheck()"></el-button>
   </span>

   <el-table style="margin-top: 30px" v-loading="loading" :data="moneyList" @selection-change="handleSelectionChange">
     <el-table-column type="selection" width="55" align="center" />
     <el-table-column label="序号" align="center" prop="checkrecordId" />
     <el-table-column label="检查名称" align="center" prop="checkName" />
     <el-table-column label="检查时间" align="center" prop="chenckTime" width="180">
       <template slot-scope="scope">
         <span>{{ parseTime(scope.row.chenckTime, '{y}-{m}-{d}') }}</span>
       </template>
     </el-table-column>
     <el-table-column label="检查费用" align="center" prop="checkPrice" />
     <el-table-column label="检查医生" align="center" prop="doctorName" />
     <el-table-column label="患者名称" align="center" prop="patientName" />
     <el-table-column label="科室" align="center" prop="deptName" />

   </el-table>
   <h1 align="center">费用总计：{{moneyTotal}}</h1>
 </div>

</template>

<script>
import {  ListMoneycheck  } from "@/api/outpatient/money";

export default {
  data() {
    return {
      moneyList:{},
      ids:[],
      prices:[],
      moneyTotal:0,

      times:{
        startTime:'',
        endTime:''
      }

    }
  },
  created() {
    this.selectMoneyCheck();
  },
  methods:{
    selectMoneyCheck(){
      ListMoneycheck(this.times).then(res=>{
        this.moneyList=res.rows;
      })
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.checkrecordId)
      this.prices = selection.map(item => item.checkPrice)
      this.moneyTotal=0;
      for(let i=0;i<this.prices.length;i++){
          this.moneyTotal+=this.prices[i];
      }
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
  }
}
</script>
